package com.xxx.controller;

import com.xxx.common.AppResult;
import com.xxx.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/test")
@RestController
@Api(tags = "测试接口")
public class TestController {

    @GetMapping("/exception")
    @ApiOperation("测试接口1: 显示异常信息")
    public AppResult testException() throws Exception {
        throw new Exception("这是一个Exception....");
    }

    @ApiOperation("测试接口2: 显示自定义异常信息")
    @GetMapping("/applicationException")
    public AppResult applicationException(){
        throw new ApplicationException("这是一个applicationException....");
    }
    @PostMapping("/hello")
    @ApiOperation("测试接口3: hello! 用户名")
    public AppResult hello(@ApiParam("姓名") @RequestParam("name") String name){
        return AppResult.success("hello!" + name);
    }
}
